package com.set;

import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import com.teach.Student1;
import com.teach.Student2;

public class Hashset1 {
	public static void main(String[] args) {
		Set<Long> set1 = new HashSet<Long>();
		System.out.println("set1.add(1L):"+set1.add(1L));
		System.out.println("set1.add(2L):"+set1.add(2L));
		System.out.println("set1.add(3L):"+set1.add(3L));
		System.out.println("set1.add(2L):"+set1.add(2L));
		System.out.println("set1="+set1);
		
		List<Long> list = Arrays.asList(1l,2l,3l,4l);
		System.out.println("list:"+list);
		Set<Long> set2 = new HashSet<Long>(list);
		System.out.println("set2="+set2);
		
		Set<Student1> set3 = new HashSet<Student1>();
		set3.add(new Student1("aaa",1l));
		set3.add(new Student1("bbb",3l));
		set3.add(new Student1("ccc",2l));
		set3.add(new Student1("ddd",3l));
		System.out.println("set3:"+set3);
		
		Set<Student2> set4 = new HashSet<Student2>();
		set4.add(new Student2("aaa",1l));
		set4.add(new Student2("bbb",3l));
		set4.add(new Student2("ccc",2l));
		set4.add(new Student2("ddd",3l));
		System.out.println("set4:"+set4);
		Student2 s1 = new Student2("eee",4l);
		set4.add(s1);
		System.out.println("set4:"+set4);
		s1.setId(1l);
		s1.setName("aaa");
		System.out.println("set4:"+set4);
		set4 = new HashSet<Student2>(set4);
		System.out.println("set4:"+set4);
		set4.add(null);
		set4.add(null);
		set4.add(null);
		set4.add(null);
		set4.add(null);
		System.out.println("set4:"+set4);
	}

}
